-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a setting for enabling iterator caching #263
Conversation
c58327b
to
86948d3
Compare
86948d3
to
c628d5a
Compare
@Andrew-Chen-Wang Thoughts on this? |
Gentle bump - any updates on this? |
with self.assertNumQueries(1): | ||
with self.assertNumQueries(2): | ||
data1 = list(Test.objects.iterator()) | ||
with self.assertNumQueries(0): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you remove these assertions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I did. Since I defaulted the setting to False
this should run 2 queries. The below block now does what this block did before.
lgtm thank you |
thx for this. I don't think it's a breaking change albeit a changing behavior. As they say, don't add performance improvements until you notice performance hits. If people notice a slowdown, I'm sure they can check the CHANGELOG to see this change and re-enable the setting. |
The latest version of django-cachalot disables caching iterators by default. See noripyt/django-cachalot#263.
The latest version of django-cachalot disables caching iterators by default. See noripyt/django-cachalot#263.
The latest version of django-cachalot disables caching iterators by default. See noripyt/django-cachalot#263.
Fixes #256
Description
This adds a setting to enable caching query results when they're generators.
Rationale
Caching iterators causes OOM errors as documented in #256 when using
QuerySet.iterator
for large result sets because of list coercion.I defaulted this setting to
False
since I think that's less surprising behavior, but this does change the existing behavior, so it would be a breaking change. Let me know if I should invert it to cache iterators by default as it currently does.